package com.ssm.exception;

import com.ssm.bean.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice //全局异常处理注解
public class ExceptionAdaptController {
    @ExceptionHandler(RuntimeException.class) //指定运行时异常处理
    public Result runTimeException(RuntimeException exception) {
        exception.printStackTrace();
        return Result.fail();
    }

    @ExceptionHandler(Exception.class)
    public Result runTimeException(Exception exception) {
        exception.printStackTrace();
        return Result.fail();
    }
}
